<template>
    <div class="box">
        <van-nav-bar title="首页" />
        <!-- <van-swipe :autoplay="3000" lazy-render>
            <van-swipe-item v-for="image in list" :key="image">
                <img :src="image.image_src" style="width: 100%;"/>
            </van-swipe-item>
        </van-swipe> -->
        <lunbo :list="list"></lunbo>

        <van-grid :border="false" :column-num="2">
            <van-grid-item v-for="(v, i) in user" :key="i" @click="detlFun(v.goods_id)">
                <lazy-component>
                    <van-image
                        :src="v.goods_small_logo ? v.goods_small_logo : 'https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg'" />
                </lazy-component>
                <p>{{ v.goods_name }}</p>
            </van-grid-item>
        </van-grid>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import { swiperdataApi, searchApi } from '@/api/api';
import lunbo from '@/components/lunbo.vue';
const images = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg',
];
let list = ref("")
const getlist = () => {
    swiperdataApi().then(res => {
        list.value = res.data.message
    })
}
getlist()

let user = ref("")
const userlisr = () => {
    searchApi().then(res => {
        user.value = res.data.message.goods
    })
}
userlisr()

import { useRoute, useRouter } from 'vue-router'
const router = useRouter()
const route = useRoute()

const detlFun = (goods_id) => {
    router.push({ path: '/detlel', query: { goods_id: goods_id } })
}
</script>

<style lang="scss" scoped></style>